package cn.com.sparkle.paxos.net.netlayer.raptor;

import cn.com.sparkle.paxos.net.frame.FrameBody;
import cn.com.sparkle.paxos.net.netlayer.NetCloseException;
import cn.com.sparkle.paxos.net.netlayer.PaxosSession;
import cn.com.sparkle.raptor.core.protocol.MultiThreadProtecolHandler.ProtocolHandlerIoSession;
import cn.com.sparkle.raptor.core.transport.socket.nio.exception.SessionHavaClosedException;

public class RaptorPaxosSession extends PaxosSession {
	ProtocolHandlerIoSession session;

	public RaptorPaxosSession(ProtocolHandlerIoSession session) {
		this.session = session;
	}

	@Override
	public void write(FrameBody message) throws NetCloseException {
		try {
			session.writeObject(message);
		} catch (SessionHavaClosedException e) {
			throw new NetCloseException(e);
		}
	}

	@Override
	public void closeSession() {
		session.closeSession();
	}
}
